-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create VJP perf fix #4806
Create VJP perf fix #4806
Conversation
Hello. You may have forgotten to update the changelog!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v0.33.1-rc0 #4806 +/- ##
============================================
Coverage 99.64% 99.64%
============================================
Files 380 380
Lines 34266 34285 +19
============================================
+ Hits 34145 34164 +19
Misses 121 121
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! It would be nice to have the list of cases where the it becomes slower because of the fallback. What I can identify is the following:
The performance is better:
- Single measurement (not tensorflow) with parameters of the same shape.
- Multiple measurements with same shapes and with parameters of the same shape.
The performance is worse:
- Parameters of the different shapes.
- Tensorflow in general takes a hit because it does not support
@
for mulitplication - Mixing measurements with different shapes is slower because of the fallback in the
compute_vjp_multi
.
In the future we should come back to dispatch the cases properly.
try-except generally hurts performance. I made a table of when we need which try-excepts so we can improve this in the future:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We made a small table of what cases need what try expect and it also show which one are better and which one become worse. It will be easier to come back to this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance improvements for the vast majority of hpc cases we care about, at the cost of a penality for edge cases and tensorflow. I find that to be an acceptable tradeoff.
While this code could probably always use more fine-tuning, this makes accomplishes exactly what it needs to accomplish,
Note that these changes have been reviewed and released already, they just aren't on master. **Context:** Bugfix release v0.33.1 had a change that isn't on master, so this gets them onto master **Description of the Change:** All I did was run `git merge v0.33.1`, then resolve conflicts. **Benefits:** Docs are in order, and the performance patch is on master. **Possible Drawbacks:** N/A For reference, these are the changes that were added in v0.33.1: v0.33.0...v0.33.1 - this PR has less files because all of the little fixes were already on master. It was only #4806 that never made it to master. --------- Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Romain Moyard <rmoyard@gmail.com> Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> Co-authored-by: Isaac De Vlugt <isaacdevlugt@gmail.com> Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com> Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: Lee James O'Riordan <mlxd@users.noreply.github.com> Co-authored-by: BM7878 <117289949+BM7878@users.noreply.github.com> Co-authored-by: Josh Izaac <josh146@gmail.com>
Before submitting
Please complete the following checklist when submitting a PR:
All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to the
test directory!
All new functions and code must be clearly commented and documented.
If you do make documentation changes, make sure that the docs build and
render correctly by running
make docs
.Ensure that the test suite passes, by running
make test
.Add a new entry to the
doc/releases/changelog-dev.md
file, summarizing thechange, and including a link back to the PR.
The PennyLane source code conforms to
PEP8 standards.
We check all of our code against Pylint.
To lint modified files, simply
pip install pylint
, and thenrun
pylint pennylane/path/to/file.py
.When all the above are checked, delete everything above the dashed
line and fill in the pull request template.
Context: v0.33.1 backport of PR #4792
Description of the Change: Updates VJP pipeline to favour direct matrix-vector products where possible.
Benefits: Improves performance for many parameter/many observable workloads
Possible Drawbacks:
Related GitHub Issues: #4792